//
//  ViewController.m
//  控制器的view的显示
//
//  Created by J on 15/11/23.
//  Copyright © 2015年 J. All rights reserved.
//

#import "ViewController.h"
#import "TestViewController.h"
#import "OneViewController.h"
#import "TwoViewController.h"
#import "ThreeViewController.h"
@interface ViewController ()
@property(nonatomic,strong)TestViewController  * VC;


@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
   
#warning    当2个控制器的view互为父子关系 那么这2个控制器最好也互为父子关系
//    [a.view addSubview:b.view];
//    [b addChildViewController:b];
    
    
    
    
    OneViewController * one = [OneViewController new];
    one.view.frame = CGRectMake( 10, 70, 400, 400);
    [self addChildViewController:one];
    
    TwoViewController * two = [TwoViewController new];
    two.view.frame = CGRectMake( 10, 70, 400, 400);
    [self addChildViewController:two];
    
    ThreeViewController * three = [ThreeViewController new];
    three.view.frame = CGRectMake( 10, 70, 400, 400);
    [self addChildViewController:three];
    
    
}
//即将旋转到某个屏幕时调用
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
//    NSLog(@"%zd %f",toInterfaceOrientation,duration);
    
    
    
}


//旋转完毕调用
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{
    
//    NSLog(@"%zd",fromInterfaceOrientation);

}


- (IBAction)vc1:(id)sender {
    OneViewController * one = self.childViewControllers[0];
//    TwoViewController * two = self.childViewControllers[1];
//    ThreeViewController * three = self.childViewControllers[2];
//    [two.view removeFromSuperview];
//    [three.view removeFromSuperview];
    [self.view addSubview:one.view];

}

- (IBAction)vc2:(id)sender {
    
    OneViewController * one = self.childViewControllers[0];
    TwoViewController * two = self.childViewControllers[1];
    ThreeViewController * three = self.childViewControllers[2];
//    [one.view removeFromSuperview];
//    [three.view removeFromSuperview];
    [self.view addSubview:two.view];

}


- (IBAction)vc3:(id)sender {
    
    
    OneViewController * one = self.childViewControllers[0];
    TwoViewController * two = self.childViewControllers[1];
    ThreeViewController * three = self.childViewControllers[2];
//    [one.view removeFromSuperview];
//    [two.view removeFromSuperview];
    [self.view addSubview:three.view];

}



@end
